<template>
  <div class="app-container">
    <div class="search-bar">
      <el-form ref="queryFormRef" :model="queryParams" :inline="true">
        <el-form-item prop="keywords" label="关键字">
          <el-input
            v-model="queryParams.keywords"
            placeholder="标题名称"
            clearable
            @keyup.enter="handleQuery"
          />
        </el-form-item>
        <el-form-item>
          <el-button type="primary" icon="search" @click="handleQuery">搜索</el-button>
          <el-button icon="refresh" @click="handleResetQuery">重置</el-button>
        </el-form-item>
      </el-form>
    </div>
  </div>
</template>

<script lang="ts" setup>
import JobApi, { JobPageQuery, JobPageVO } from "@/api/job/job.api";

defineOptions({
  name: "Job",
  inheritAttrs: false,
});

const queryFormRef = ref();

const loading = ref(false);
const total = ref(0);

const queryParams = reactive<JobPageQuery>({
  pageNum: 1,
  pageSize: 10,
});

// 兼职表格数据
const jobList = ref<JobPageVO[]>();

// 查询
function handleQuery() {
  loading.value = true;
  JobApi.getPage(queryParams)
    .then((data) => {
      jobList.value = data.list;
      total.value = data.total;
    })
    .finally(() => {
      loading.value = false;
    });
}

// 重置查询
function handleResetQuery() {
  queryFormRef.value.resetFields();
  queryParams.pageNum = 1;
  handleQuery();
}
</script>

<style lang="scss" scoped></style>
